package com.snopy.designPattern.structure.proxy;

import com.snopy.designPattern.structure.proxy.inter.ThirdPartyYouTubeLib;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;

/**
 * @author snopy
 * @version 1.0.0
 * @classname YouTubeDownloader
 * @description
 * @email 77912204@qq.com
 * @date 2022/03/03 21:57
 */
@Slf4j
public class YouTubeDownloader {
    private ThirdPartyYouTubeLib api;

    public YouTubeDownloader(ThirdPartyYouTubeLib api) {
        this.api = api;
    }
    public void renderVideoPage(String videoId){
        Video video = api.getVideo(videoId);
        log.info("\n-------------------------");
        log.info("Video page(imagine fancy HTML)");
        log.info("ID:{}",video.getId());
        log.info("Title:{}",video.getTitle());
        log.info("Video:{}",video.getData());
        log.info("---------------------------");
    }
    public void renderPopularVideos(){
        HashMap<String,Video> list = api.popularVideos();
        log.info("\n----------------------------------");
        log.info("Most popular videos on YouTube (imageine fancy HTML)");
        for (Video video:list.values()){
            log.info("ID: {} / Title:{}",video.getId(),video.getTitle());
        }
        log.info("------------------------------------");
    }
}
